package com.donleo.ssm.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * @author liangd
 * date 2020-11-17 16:42
 * code 用户表
 */
public class UserModel extends BaseModel {
    /**
     * 用户Id
     */
    private Integer id;
    /**
     * 学号
     */
    private Integer studentId;
    /**
     * 用户名
     */
    private String username;
    /**
     * 密码
     */
    private String password;
    /**
     * 性别
     */
    private String gender;
    /**
     * 年龄
     */
    private Integer age;
    /**
     * 电话
     */
    private String phone;
    /**
     * 邮箱
     */
    private String email;
    /**
     * 爱好
     */
    private String hobby;
    /**
     * 生日
     * <p>
     * 使用@RequestBody 转换时间，需要加JsonFormat
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date birthday;
    /**
     * 头像地址
     */
    private String avatar;
    /**
     * 学历
     */
    private String degree;
    /**
     * 队伍
     */
    private String team;
    /**
     * 籍贯
     */
    private String hometown;
    /**
     * 地址
     */
    private String address;
    /**
     * 是否冻结
     */
    private String accountEnable;
    /**
     * 自我介绍
     */
    private String introduce;
    /**
     * 验证码
     */
    private String code;
     /**
     * 用户角色
     *      1、超级管理员
     *      2、管理员
     *      3、班主任
     *      4、科任老师
     *      5、助教
     *      6、组长
     *      7、学生
     */
    private Integer userRole;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getStudentId() {
        return studentId;
    }

    public void setStudentId(Integer studentId) {
        this.studentId = studentId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getHobby() {
        return hobby;
    }

    public void setHobby(String hobby) {
        this.hobby = hobby;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getDegree() {
        return degree;
    }

    public void setDegree(String degree) {
        this.degree = degree;
    }

    public String getTeam() {
        return team;
    }

    public void setTeam(String team) {
        this.team = team;
    }

    public String getHometown() {
        return hometown;
    }

    public void setHometown(String hometown) {
        this.hometown = hometown;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getAccountEnable() {
        return accountEnable;
    }

    public void setAccountEnable(String accountEnable) {
        this.accountEnable = accountEnable;
    }

    public String getIntroduce() {
        return introduce;
    }

    public void setIntroduce(String introduce) {
        this.introduce = introduce;
    }

    public Integer getUserRole() {
        return userRole;
    }

    public void setUserRole(Integer userRole) {
        this.userRole = userRole;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    /*****************返回数据格式转换**********************/
    /**
     * 性别中文显示
     */
    private String genderStr;

    /**
     * 数据是否可用
     */
    private String accountEnableStr;
    /**
     * 学历
     */
    private String degreeStr;

    /*****************getter**********************/
    public String getGenderStr() {
        if ("male".equals(gender)) {
            genderStr = "男";
        }
        if ("female".equals(gender)) {
            genderStr = "女";
        }
        if ("secret".equals(gender)) {
            genderStr = "保密";
        }
        return genderStr;
    }

    public String getAccountEnableStr() {
        if ("regular".equals(accountEnable)){
            accountEnableStr="正常";
        }
        if ("frozen".equals(accountEnable)){
            accountEnableStr="冻结";
        }
        return accountEnableStr;
    }

    public String getDegreeStr() {
        if ("primary".equals(degree)){
            degreeStr="小学";
        }
        if ("junior".equals(degree)){
            degreeStr="初中";
        }
        if ("high".equals(degree)){
            degreeStr="高中";
        }
        if ("college".equals(degree)){
            degreeStr="大专";
        }
        if ("university".equals(degree)){
            degreeStr="本科";
        }
        if ("master".equals(degree)){
            degreeStr="硕士";
        }
        if ("doctor".equals(degree)){
            degreeStr="博士";
        }
        return degreeStr;
    }


    /*****************setter**********************/
    public void setGenderStr(String genderStr) {
        this.genderStr = genderStr;
    }

    public void setAccountEnableStr(String accountEnableStr) {
        this.accountEnableStr = accountEnableStr;
    }

    public void setDegreeStr(String degreeStr) {
        this.degreeStr = degreeStr;
    }
}
